package com.sean.test

import com.xmh.code.PingApplication
import com.xmh.code.service.PingService
import org.apache.rocketmq.spring.core.RocketMQTemplate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import spock.lang.Specification

@SpringBootTest(classes = [PingApplication], properties = [
        "rocketmq.producer.group=PingServiceSpecProducer",
        "rocketmq.consumer.group=PingServiceSpecConsumer"
])
class PingServiceSpec extends Specification {

    @Autowired
    private PingService exampleService
    @MockBean
    private RocketMQTemplate rocketMQTemplate;

    def "test pingService method"() {
        given:
        String input = "test"
//        when(rocketMQTemplate.sendOneWay(input))
        when:
        exampleService.pingService(input)

        then: "Verify"
        1 == 1
    }

    def "test pingPongService method"() {
        given:
        String input = "test"
//        when(rocketMQTemplate.sendOneWay(input))
        when:
        exampleService.pingPongService()
        exampleService.pingPongService2()
        exampleService.pingPongService3()
        exampleService.pingPongService4()

        then:
        1 == 1
    }
}
